﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IM.Domain.Repository
{
    public abstract class RepositoryLocatorBase: IRepositoryLocator
    {
        #region IRepositoryLocator Members

        public TEntity Save<TEntity>(TEntity entity)
        {
            return GetRepository<TEntity>().Save(entity);     
        }

        public bool Update<TEntity>(TEntity entity)
        {
            return GetRepository<TEntity>().Update(entity);
        }

        public bool Delete<TEntity>(TEntity entity)
        {
            return GetRepository<TEntity>().Delete(entity);
        }

        public TEntity GetByID<TEntity>(long iD)
        {
            return GetRepository<TEntity>().GetByID(iD);
        }

        public IQueryable<TEntity> GetAll<TEntity>()
        {
            return GetRepository<TEntity>().GetAll();
        }

        public abstract IRepository<TRepository> GetRepository<TRepository>();

        #endregion
    }
}
